test: stabilize source regression assertions for current UI#805
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughThe PR updates audit regression tests for service comparison, seeded form provenance, source-link rendering, private API gating, polling and mutation contracts, and the root dashboard heading. ChangesContent-service audit updates
Navigation and authentication audit updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/audit-content-services-regressions.test.ts`:
- Around line 206-207: Update the normalizedFormDetailSource matcher in the
anchor-label regression test so the pattern cannot cross the closing </a> tag
before matching “Official”. Keep the assertion focused on the <a
href={form.source.url}> element and require “Official” within that anchor’s
contents; retain the separate formDetailSource containment check only if it
remains necessary.
In `@tests/audit-navigation-auth-regressions.test.ts`:
- Around line 124-126: Update the heading assertion in the “keeps the root
dashboard H1 as Clinical KB” test to match only the exact “Clinical KB” text,
removing the alternation that also permits “Clinical Guide”; preserve the
existing H1 structure and whitespace handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5b467aa4-640f-4c68-ba06-405f6c856959
📒 Files selected for processing (2)
tests/audit-content-services-regressions.test.tstests/audit-navigation-auth-regressions.test.ts
| expect(normalizedFormDetailSource).toMatch(/<a href=\{form\.source\.url\}[^>]*>[\s\S]*Official/); | ||
| expect(formDetailSource).toContain("Official"); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Constrain “Official” to the source URL anchor.
This matcher can cross </a> and pass on an unrelated later “Official” string, so it does not reliably protect the anchor label contract.
Proposed fix
- expect(normalizedFormDetailSource).toMatch(/<a href=\{form\.source\.url\}[^>]*>[\s\S]*Official/);
+ expect(normalizedFormDetailSource).toMatch(
+ /<a href=\{form\.source\.url\}[^>]*>(?:(?!<\/a>)[\s\S])*Official/,
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(normalizedFormDetailSource).toMatch(/<a href=\{form\.source\.url\}[^>]*>[\s\S]*Official/); | |
| expect(formDetailSource).toContain("Official"); | |
| expect(normalizedFormDetailSource).toMatch( | |
| /<a href=\{form\.source\.url\}[^>]*>(?:(?!<\/a>)[\s\S])*Official/, | |
| ); | |
| expect(formDetailSource).toContain("Official"); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/audit-content-services-regressions.test.ts` around lines 206 - 207,
Update the normalizedFormDetailSource matcher in the anchor-label regression
test so the pattern cannot cross the closing </a> tag before matching
“Official”. Keep the assertion focused on the <a href={form.source.url}> element
and require “Official” within that anchor’s contents; retain the separate
formDetailSource containment check only if it remains necessary.
| it("keeps the root dashboard H1 as Clinical KB", () => { | ||
| expect(clinicalDashboardSource.match(/<h1\b/g)).toHaveLength(1); | ||
| expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical Guide\s*<\/h1>/); | ||
| expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical (?:Guide|KB)\s*<\/h1>/); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Require the exact Clinical KB heading.
This regex accepts the old Clinical Guide value, so the test passes against the supplied src/components/ClinicalDashboard.tsx implementation even though the test name requires Clinical KB. Use an exact Clinical KB match, or retain an exact Clinical Guide expectation if no UI change is intended.
Proposed fix
- expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical (?:Guide|KB)\s*<\/h1>/);
+ expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical KB\s*<\/h1>/);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it("keeps the root dashboard H1 as Clinical KB", () => { | |
| expect(clinicalDashboardSource.match(/<h1\b/g)).toHaveLength(1); | |
| expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical Guide\s*<\/h1>/); | |
| expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical (?:Guide|KB)\s*<\/h1>/); | |
| it("keeps the root dashboard H1 as Clinical KB", () => { | |
| expect(clinicalDashboardSource.match(/<h1\b/g)).toHaveLength(1); | |
| expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical KB\s*<\/h1>/); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/audit-navigation-auth-regressions.test.ts` around lines 124 - 126,
Update the heading assertion in the “keeps the root dashboard H1 as Clinical KB”
test to match only the exact “Clinical KB” text, removing the alternation that
also permits “Clinical Guide”; preserve the existing H1 structure and whitespace
handling.
Summary
Verification
npx vitest run tests/audit-content-services-regressions.test.ts tests/audit-navigation-auth-regressions.test.ts=> 2 passed, 11 passed (11)npx prettier --write tests/audit-content-services-regressions.test.ts tests/audit-navigation-auth-regressions.test.tsnpx verify:cheap— not run (outside this test-only fix scope; may require longer runtime)